{% extends "master.html" %}
{% block subtitle %} - 主面板 - 仓位管理 - 商品清单{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    function toSbumit(){
        $(".searchForm").attr('action',"{{url_for('.view',action='viewProduct',id=obj.id)}}");
        $(".searchForm").submit();
    }
    
    function toExport(){
        $(".searchForm").attr('action',"{{url_for('.view',action='export',id=obj.id)}}");
        $(".searchForm").submit();
    }
    
    function toUpdate(){
        clearMsg();
        var msg = [];
        if($("input[name='pdt_ivt']:checked").length < 1){
            msg.push('请选择至少一条记录以进行该操作！');
        }
        if(msg.length > 0 ){
            alertError(msg);
            return false;            
        }else{
            $("#dataForm").attr('action',"{{url_for('.view',action='updateQty')}}");
            $("#dataForm").submit();
        }
    }
    
    function toInternal(){
        clearMsg();
        var msg = [];
        if($("input[name='pdt_ivt']:checked").length < 1){
            msg.push('请选择至少一条记录以进行该操作！');
        }
        if(msg.length > 0 ){
            alertError(msg);
            return false;            
        }else{
            $("#dataForm").attr('action',"{{url_for('.view',action='internalCreate')}}");
            $("#dataForm").submit();
        }
    }    

//]]>
</script>
{% endblock %}

{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpRoot.view')}}">主面板</a></li>
          <li><a href="{{url_for('bpIvt.view')}}">仓位管理</a></li>
          <li class="active">商品清单 [ 仓位  : {{obj.name}} ]</li>
        </ol>
    </div>
    <div class="row">
        {{mymacros.render_search_form(form,3)}}
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button type="button" class="btn btn-default" onclick="return toSbumit()">{{BTN_SEARCH}}</button></div>
            <div class="btn-group"><button type="button" class="btn btn-primary" onclick="return toUpdate()">批量修改数量</button></div>
            <div class="btn-group"><button type="button" class="btn btn-primary" onclick="return toInternal()">内部转仓</button></div>
            <div class="btn-group"><button type="button" class="btn btn-success" onclick="return toExport()">导出记录</button></div>
        </div>
    </div>
    <div class="row">
        <form method='post' action="{{ url_for('bpIvt.view',action='updateQty') }}" enctype="multipart/form-data" id="dataForm">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <td><input type="checkbox" onclick="selectall(this,'pdt_ivt')"/></td>
                    <th>商品名称</th>
                    <th>现存数量</th>
                    <th>入库时间</th>
                    <th>更新时间</th>
                </tr>
            </thead>
            <tbody>
                {% for (pdt,r) in result %}
                    <tr>
                        <td><input type="checkbox" name="pdt_ivt" value="{{r.pdtID}}_{{r.ivtID}}"/></td>
                        <td>{{mymacros.render_goto_popup_pdt(pdt, loop.first)}}</td>
                        <td>{{r.qty}}</td>
                        <td>{{r.createTime|ft}}</td>
                        <td>{{r.updateTime|ft}}</td>
                    </tr>
                {% endfor %}
            </tbody>                
        </table>
        </form>
        {{mymacros.mypaginate(result)}}
    </div>
    
 
</div>
{% endblock %}